package cn.tedu.boot11.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@Controller
public class HelloController {

    @RequestMapping("/hello")
    public void hello(HttpServletResponse response) throws IOException {
        System.out.println("接收到了请求!");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter pw = response.getWriter();
        pw.print("我是服务器,我接收到了你的请求!");
        pw.close();
    }


    @RequestMapping("/hello2")
    @ResponseBody //作用:以返回值的方式给客户端响应数据
    public String hello2(){
        return "我是服务器,我接收到了你的请求!";
    }

}
